package com.boot.main.controller;

import com.boot.main.entity.BcomCategory;
import com.boot.main.entity.BcomSite;
import com.boot.main.service.ISiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/v1/api")
@Api(tags = "书签管理")
public class SiteController {
    @Resource
    private ISiteService siteService;

    @RequestMapping(value="/blog/sites", method = RequestMethod.GET)
    @ApiOperation(value="获取书签列表")
    public Object getSites(@RequestParam("page") Integer page, @RequestParam("limit") Integer limit, @RequestParam("cid") Long cid, @RequestParam("username") String username){
        return siteService.getSites(page, limit, cid, username);
    }

    @RequestMapping(value="/blog/site/user", method = RequestMethod.GET)
    @ApiOperation(value="获取书签列表")
    public Object getSiteUser(@RequestParam("page") Integer page, @RequestParam("limit") Integer limit){
        return siteService.getSiteUser(page, limit);
    }

    @RequestMapping(value="/blog/site/{id}", method = RequestMethod.GET)
    @ApiOperation(value="获取书签詳情")
    public Object getSiteById(@PathVariable Long id){
        return siteService.getSiteById(id);
    }

    @RequestMapping(value="/site", method = RequestMethod.POST)
    @ApiOperation(value="新增书签")
    public Object saveSite(@RequestBody BcomSite site){
        return siteService.saveSite(site);
    }

    @RequestMapping(value="/site/{id}", method = RequestMethod.PUT)
    @ApiOperation(value="修改书签")
    public Object updateSite(@RequestBody BcomSite site){
        return siteService.updateSite(site);
    }

    @RequestMapping(value="/site/{id}", method = RequestMethod.DELETE)
    @ApiOperation(value="删除书签")
    public Object deleteSite(@PathVariable Long id){
        return siteService.deleteSite(id);
    }
}
